/*
 * Handle.h
 *
 *  Created on: 2014. 6. 25.
 *      Author: jjaehuny
 */

#ifndef FRAMEWORK_TIMER_HANDLE_H_
#define FRAMEWORK_TIMER_HANDLE_H_

#include <memory>
#include <functional>

#include <boost/system/error_code.hpp>
#include <boost/function.hpp>

namespace Framework { namespace Timer {

class Handle;
std::shared_ptr<Handle> create_handle_singlethread();
std::shared_ptr<Handle> create_handle_multithread();

} /*Timer*/ } /*Framework*/



namespace Framework { namespace Timer {

class Handle
{
public:
	/// engine call logic multithread
	typedef boost::function<void(const boost::system::error_code &, int)> OBSERVER;

public:
	Handle();
	virtual ~Handle();

	/// call from pool
	void Initialize();
	void Finalize();

	/// call from logic
	void SetTimer(int milliseconds, int id, OBSERVER observer);
	void KillTimer();

private:
	struct Pimple;
	std::unique_ptr<Pimple> This;
};

} /*Timer*/ } /*Framework*/

#endif /* FRAMEWORK_TIMER_HANDLE_H_ */
